define(['jquery'],()=>{
    $('header').load('/html/header.html',()=>{

    })
    $('.main-search').load('/html/main-search.html',()=>{
        // 跳转购物车
        $('.cart-box').click((e)=>{
            e.preventDefault()
            location.href = '/html/shoppingcart.html'
        })
        // 跳转首页
        $('.log').click((e)=>{
            e.preventDefault()
            location.href = '/index.html'
        })
        
        function cart_num(){
            // location.replace() 
            let span = document.querySelector('.total')
            let list = JSON.parse(localStorage.getItem('cart')) || []
            let num = 0
            list.forEach(item=>{
                num += item.cart_number
            })
            span.innerHTML =num
            return
        }
        cart_num()
    })
    $('nav').load('/html/nav.html',()=>{
        // 跳转品牌分类
        $('.l1').click((e)=>{
            e.preventDefault()
            location.href = '/html/brand.html'
        })
        // 跳转首页
        $('.l2').click((e)=>{
            e.preventDefault()
            location.href = '/index.html'
        })
        // 跳转微信素材
        $('.l3').click((e)=>{
            e.preventDefault()
            location.href = '/html/wechat.html'
        })
    })
    $('.list').load('/html/list.html')
    $('footer').load('/html/footer.html')
       
})